<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/ztree/jquery.ztree.core-3.5.js" type="text/javascript"></script>
<script type="text/javascript">
$("#deliver").select2();
    var setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        callback:{
            onClick: zTreeOnClick
        }
    };

    var zNodes =[
    <?php foreach($departs as  $item):?>
    {id:<?php echo $item['id'];?>, pId:<?php echo $item['pid'];?>, name:"<?php echo $item['name'];?>",<?php echo $item['id']==1 ? "open: true" : '' ;?>},
    <?php endforeach;?>
    ];

    function zTreeOnClick( event, treeId, treeNode){
      var depart_id = treeNode.id;
        $.get("/DetectScheduling/get_checker", {"depart_id": depart_id}, function (data) {
            var optstr = '';
            if (data.code == 200) {
                console.log(data.data);
                $.each(data.data, function (k, val) {
                    optstr += "<option value='" + val.emp_id + "'>" + val.real_name + "</option>"
                })
            }
            $("#checker").html(optstr);
        }, "json");
        $("#checker_id").val(treeNode.id);
        $("#onadd").val(treeNode.name);
        $(".select-box .zTreeDemoBackground").fadeOut();
    }
    $(document).ready(function(){
        $.fn.zTree.init($("#tree"), setting, zNodes);

        $(".select-box .menList").click(function(){
            $(".select-box .zTreeDemoBackground").fadeToggle();
            $("#tree").show();
        })

        $(".select-box .menList").click(function(event){
                $(this).siblings("ul").fadeIn()
                $(this).parent().siblings("li").find("ul").fadeOut();
                event.stopPropagation();
        });

        $("body").click(function(event){
            $(".select-box .menbox").fadeOut();
            $(".select-box .zTreeDemoBackground").fadeOut();
            event.stopPropagation();
        })
        $(".zTreeDemoBackground").click(function(event){
             event.stopPropagation();
        })
    });

    function popup(opp){
         $(opp).parent().siblings("input").val($(opp).html());
         $(opp).parent().fadeOut();
    }
</script>

<style>
.select-box{
    float:left; position: relative;
}
.select-box .menList{background: #fff url(http://img3.isou365.cn/paimai/yunying/images/sanjiao.jpg) no-repeat 200px 7px;
    display: block;
    cursor: pointer;
    text-align: center;
    width: 200px;
    border:solid 1px #d2d2d2;
    height:24px; line-height: 24px;
    float: left;
    }
    .select-box .zTreeDemoBackground{ display: none; position: absolute;left:0;top:26px; background:#fff;}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar" menu="cljc.jcdd"/>
    <div class="mianR">
        <h3 class="yonghu">分配基本信息</h3>
        <div class="chezhu-xinxi">
            <div class="xinxi-conter" style="background: none;border: none;">
                <h4 class="order_no">车主ID: <b>{$owner.owner_id}</b></h4>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车主信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>车主姓名</em>
                        <em class="name-text1">{$owner.seller_name}</em>
                        <em>车主电话</em>
                        <em class="name-text">{$owner.phone}</em>
                    </li>
                    <li class="clearfix">
                        <em>车主类型</em>
                        <em class="name-text1">{$owner.owner_type_name}</em>
                        <if condition="$owner.owner_type eq 1">
                            <em>车主姓名</em>
                            <em class="name-text">{$owner.seller_name}</em>
                            <else />
                            <em>公司名称</em>
                            <em class="name-text">{$owner.seller_name}</em>
                        </if>
                    </li>
                    <li class="clearfix">
                        <if condition="$owner.owner_type eq 1">
                            <em>联系电话</em>
                            <em style="width: 875px;" class="name-text">{$owner.phone}</em>
                            <else />
                            <em>联系人姓名</em>
                            <em class="name-text1">{$owner.contact_person}</em>
                            <em>联系电话</em>
                            <em class="name-text">{$owner.phone}</em>
                        </if>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车辆信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>车型</em>
                        <em class="name-text1">{$owner.car_model}</em>
                        <em>行驶里程</em>
                        <em class="name-text">{$owner.mileage} 公里</em>
                    </li>
                    <li class="clearfix">
                        <em>上牌时间</em>
                        <em class="name-text1">{$owner.first_reg_date}</em>
                        <em>车辆所在地</em>
                        <em class="name-text">{$owner.location_area}</em>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>预约信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>客服人员</em>
                        <em class="name-text1">{$owner.server}</em>
                        <em>预约时间</em>
                        <em class="name-text">{:transform_date($owner['reserve_time'])}</em>
                    </li>
                    <li class="clearfix">
                        <em>预约地址</em>
                        <em style="width: 875px;" class="name-text">{$owner.address}</em>
                    </li>
                    <li class="clearfix">
                        <em>预约备注</em>
                        <em style="width: 875px;" class="name-text">{$owner.reserve_remark}</em>
                    </li>
                </ul>
            </div>
            <br/>
            <if condition="$owner.check_fail_type eq 4">
                <volist name="car_check_log" id="vo">
                    <div class="xinxi-conter xinxi-conter1">
                        <h4>检测信息</h4>
                        <ul>
                            <li class="clearfix">
                                <em>评估师</em>
                                <em class="name-text1">{$vo.checker}</em>
                                <em>退单时间</em>
                                <em class="name-text">{$vo.createtime}</em>
                            </li>
                            <li class="clearfix">
                                <em>退单备注</em>
                                <em style="width: 875px;" class="name-text">{$vo.remark}</em>
                            </li>
                        </ul>
                    </div>
                    <br/>
                </volist>
            </if>
            <div class="xinxi-conter xinxi-conter1">
                <h4>滞留信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>滞留备注</em>
                        <em style="width: 875px;"  class="name-text">{$owner.remark_fail}</em>
                    </li>
                </ul>
            </div>
            <br/>
            <!--            <div class="xinxi-conter">
                <ul>
                    <li class="clearfix">
                        <em>用户ID：</em>
                        <em class="name-text1">{$owner.owner_id}</em>
                    </li>
                    <li class="clearfix">
                        <em>预约时间</em>
                        <em class="name-text1">{:transform_date($owner['reserve_time'])}</em>
                        <em>车型</em>
                        <em class="dian-hua1">{$owner.car_model}</em>
                    </li>
                    <li class="clearfix">
                        <?php if($owner['service_method']==3):?>
                        <em>预约门店</em><em class="name-text1"><?php echo C("STORE.".$owner['reserve_store']);?></em>
                        <?php else:?>
                        <em>预约地址</em><em class="name-text1">{$owner.address}</em>
                        <?php endif;?>
                    </li>
                    <li class="clearfix">
                        <em>预约备注</em>
                        <em style="width: 845px;" class="name-text">{$owner.reserve_remark}</em>
                    </li>
                </ul>
            </div>-->
        </div>
        <h3 class="yonghu">请选择分配结果</h3>
        <div class="yuyue">
            <ul>
                <li class="yuCurrent" onclick="setStatus(1);">分配成功</li>
                <li onclick="setStatus(2);">滞留</li>
                <li onclick="setStatus(3);">改约</li>
            </ul>
            <input type="hidden" id="fenpei_type" name="fenpei_type" value="1" />
            <input type="hidden" name="again" id="again" value="{$again}" />
        </div>
        <div class="listBox">
            <div class="yuList">
                <div class="distribution">
                    <form id="distributeForm">
                        <dl class="clearfix">
                            <dt>分配到</dt>

                            <div class="select-box">
                                 <input type="text" id="onadd" class="menList" readonly="请选择所属部门" value="请选择所属部门">
                                 <div class="zTreeDemoBackground left">
                                       <ul id="tree" class="ztree"></ul>
                                   </div>
                             </div>
                             <input type='hidden' id='checker_id' name="checker_id" value="" />
                             <div class="select-box">
                               <select name="checker_id" id="checker" style="width:162px;margin-left: 20px;">
                                   <option>请选择评估师</option>
                               </select>
                             </div>


                        </dl>
                        <dl class="clearfix">
                            <dt>备注</dt>
                            <dd><textarea name="assgin_remark"></textarea></dd>
                        </dl>
                        <input type="hidden" name="again" value="{$again}" />
                        <input type="hidden" name="owner_id" value="{$owner.owner_id}" />
                    </form>
                </div>
                <div class="yongBtn">
                    <input id="submitForm" type="button" value="确定" class="queding" />
                    <input type="button" onclick="history.back();"  class="quxiao" value="返回" />
                </div>
            </div>
            <div class="yuList" style="display:none;">
                <div class="distribution">
                    <dl class="clearfix">
                        <dt>备注</dt>
                        <dd><textarea name="assgin_remark_zl" id="assgin_remark_zl"></textarea></dd>
                    </dl>
                    <div class="yongBtn">
                        <input id="submit_zl" type="button" value="确定" class="queding" />
                        <input type="button" onclick="history.back();"  class="quxiao" value="返回" />
                    </div>
                </div>
            </div>
            <div class="yuList" style="display:none;">
                <div class="distribution">
                    <dl class="clearfix">
                        <dt>备注</dt>
                        <dd><textarea name="assgin_remark_gy" id="assgin_remark_gy"></textarea></dd>
                    </dl>
                    <div class="yongBtn">
                        <input id="submit_gy" type="button" value="确定" class="queding" />
                        <input type="button" onclick="history.back();"  class="quxiao" value="返回" />
                    </div>
                </div>
            </div>
        </div>
    </div>    
</div>

<script type="text/javascript">
    $("#store,#checker").select2();
    $("#store").change(function () {
        var store_id = $(this).val();
        $.get("/DetectScheduling/getCheckers", {"store_id": store_id}, function (data) {
            var optstr = '';
            if (data.code == 200) {
                $.each(data.data, function (k, val) {
                optstr += "<option value='" + val.emp_id + "'>" + val.real_name + "</option>"
                });
            }
            $("#checker").html(optstr);
        }, "json");
    });
    /**
     * 分配类型 1、成功 2、滞留 3、改约
     */
    function setStatus(status) {
        $("#fenpei_type").val(status);
    }
    /**
     * 分配成功
     */
    $("#submitForm").click(function () {
        $.post("/DetectScheduling/saveDistribution", $("#distributeForm").serialize(), function (data) {
            if (data.code != 200) {
                shibai_alert(data.msg);
                 return false;
            }
             btn_alert(data.msg);
            setTimeout("window.location.href='/DetectScheduling/retention'", 1500);
        }, "json");
    });
    /**
     * 滞留
     */
    $("#submit_zl").on("click", function(){
        var fenpei_type = $("#fenpei_type").val();
        var assgin_remark_zl = $("#assgin_remark_zl").val();
        var again = $('#again').val();
        var params = {
                'owner_id':{$owner.owner_id},
                'fenpei_type':fenpei_type,
                'assgin_remark_zl':assgin_remark_zl,
                'again':again
        }
        $.post("/DetectScheduling/saveDistribution", params, function(data){
            if (data.code != 200) {
                shibai_alert(data.msg);
                return false;
            }
            btn_alert(data.msg);
            setTimeout("window.location.href='/DetectScheduling/retention'", 1500);
        }, "json");
    });
    /**
     * 改约
     */
    $("#submit_gy").on("click", function(){
        var fenpei_type = $("#fenpei_type").val();
        var assgin_remark_gy = $("#assgin_remark_gy").val();
        var again = $('#again').val();
        var params = {
                 'owner_id':{$owner.owner_id},
                'fenpei_type':fenpei_type,
                'assgin_remark_gy':assgin_remark_gy,
                'again': again
        }
        $.post("/DetectScheduling/saveDistribution", params, function(data){
            if (data.code != 200) {
                shibai_alert(data.msg);
                return false;
            }
            btn_alert(data.msg);
            setTimeout("window.location.href='/DetectScheduling/retention'", 1500);
        }, "json");
    });
</script>
</body>
</html>